/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.bootstrap.client.ui;

import com.google.gwt.dom.client.Element;

/**
 * Affix toggles between three states/classes: .affix, .affix-top, and .affix-bottom. You must
 * provide the styles for these classes yourself (independent of this plugin). The .affix-top class
 * should be in the regular flow of the document. The .affix class should be position: fixed. And
 * .affix-bottom should be position: absolute. Note: .affix-bottom is special in that the plugin
 * will place the element with JS relative to the offset: { bottom: number } option you've provided.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 * @see http://getbootstrap.com/javascript/#affix
 */
public class Affix {

  /**
   * The affix offset.
   */
  public interface AffixOffset {
    /**
     * @return
     */
    int top();

    /**
     * @return
     */
    int bottom();
  }

  /**
   * Activates a element with the given offset.
   * 
   * @param e the element to be activated
   * @param offset the offset to set
   */
  public static native void activate(Element e, AffixOffset offset) /*-{
                                                                    $wnd
                                                                    .jQuery(e)
                                                                    .affix(
                                                                    {
                                                                    offset : {
                                                                    top : function() {
                                                                    return (this.top = offset.@com.cleangwt.bootstrap.client.ui.Affix.AffixOffset::top()());
                                                                    },
                                                                    bottom : function() {
                                                                    return (this.bottom = offset.@com.cleangwt.bootstrap.client.ui.Affix.AffixOffset::bottom()());
                                                                    }
                                                                    }
                                                                    });
                                                                    }-*/;

  // public static native void refresh(Element e) /*-{
  // $wnd.jQuery(e).checkPosition();
  // }-*/;

}
